﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;

public class Examination:Level
{
    public AudioSource m_StopSound;
    public AudioSource m_SucceedSound;
    public AudioSource m_BigSucceedSound;
    public AudioSource m_Tick;
    public Text m_TimeCountL;

    public Driver.DriveLevel m_DriveLevel;
    public bool m_Start = false;
    public float m_TimeMax = 30;
    public float m_TimeBigSucceedMax = 0;
    protected float m_TimeCount = 0;

    protected override void Start()
    {
        base.Start();
        m_Control.enabled = false;
#if UNITY_ANDROID
        m_Control.m_AndroidControlePanel.SetActive(false);
#endif
    }
    protected override void Update()
    {
        base.Update();
        if (!m_Start)
            return;
        m_TimeCountL.text = Convert.ToDouble(m_TimeCount).ToString("0.00") + "/" + m_TimeMax;

        m_TimeCount += Time.deltaTime;
    }
    public virtual void OnStart()
    {
        m_Start = true;
        m_Control.enabled = true;
        m_StartSound.Stop();
        m_Tick.Play();

#if UNITY_ANDROID
        m_Control.m_AndroidControlePanel.SetActive(true);
#endif
    }

    public override void OnSucceed()
    {
        base.OnSucceed();
        m_Start = false;
        m_Control.enabled = false;
        m_Tick.Stop();
    }
    protected override void OnLose()
    {
        base.OnLose();
        m_Start = false;
        m_Control.enabled = false;
        m_WarningSound.Play();
        m_StopSound.Play();

        m_Tick.Stop();
    }
}